/* userPhyAccess.h */

/************************************************************************************
*                    Copyright Aquantia Corporation
*                              Freeware
*
* Description:
*
*   Declares the base PHY register read and write functions that are 
*   called by the RPC Server functions. The platform integrator must provide 
*   the implementation of these routines.
*
************************************************************************************/

/*! \file
 * Declares the base PHY register read and write functions that are 
 * called by the RPC Server functions. The platform integrator must provide 
 * the implementation of these routines. */

#ifndef AQ_USER_PHY_ACCESS_TOKEN
#define AQ_USER_PHY_ACCESS_TOKEN

/*! \defgroup registerAccessFunctions Register Access Functions
The PHY register access functions are required by the RPC Server to access the register space
of each Aquantia PHY deployed in a system. The body of these functions needs to 
be written by the system designer, as the method of accessing the PHY will 
be unique to the target system. They are designed to be generic read and 
write access functions, as the MDIO addressing scheme relies on each 
MMD to maintain a 16 bit address pointer that determines the register where 
the next read or write is coming from. Consequently, various levels of 
optimization of the MDIO interface are possible: from re-writing the MMD 
address pointer on every transaction, to storing shadow copies of the MMD 
address pointers and only updating the MMD address pointer as necessary. 
Thus these functions leave the MDIO optimization to the system engineer.
 @{*/

/*! Provides generic synchronous PHY register write functionality. It is the
 * responsibility of the system designer to provide the specific MDIO address 
 * pointer updates, etc. in order to accomplish this write operation. 
 * It will be assumed that the write has been completed by the time this 
 * function returns.*/
void AQ_USERPA_Register_Write
(
    /*! Uniquely identifies the system (if necessary). */
  unsigned int adapter,
    /*! Uniquely identifies the port within the system. */
  unsigned int PHY_ID,
    /*! The address of the MMD within the target PHY. */
  unsigned int MMD,
    /*! The 16-bit address of the PHY register being written. */
  unsigned int address,
    /*! The 16-bits of data to write to the specified PHY register. */
  unsigned int data
);

/*! Provides generic synchronous PHY register read functionality. It is the
 * responsibility of the system designer to provide the specific MDIO address 
 * pointer updates, etc. in order to accomplish this read operation.*/
unsigned int AQ_USERPA_Register_Read
(
    /*! Uniquely identifies the system (if necessary). */
  unsigned int adapter,
    /*! Uniquely identifies the port within the system. */
  unsigned int PHY_ID,
    /*! The address of the MMD within the target PHY. */
  unsigned int MMD,
    /*! The 16-bit address of the PHY register being read. */
  unsigned int address
);

/*! The number of adapters exposed by the server. */
#define AQ_USERPA_NUM_ADAPTERS 4

/*! The maximum allowed length for each adapter name. */
#define AQ_USERPA_MAX_ADAPTER_NAME_LENGTH  30


/*@}*/

#endif
